package com.bruce.pattern.behavioral.observer;

import lombok.Getter;
import lombok.extern.slf4j.Slf4j;

import java.util.Observable;

/**
 * 即被观察者
 * <p>
 * Created by bruce on 2018/11/10 19:49
 */
@Slf4j
public class Friend extends Observable {

    @Getter
    private String nickname;

    public Friend(String nickname) {
        this.nickname = nickname;
    }

    public void sendWeibo(Weibo weibo) {
        log.info(nickname + "在" + weibo.getDateTime().toString() + "发布微博,内容是:" + weibo.getContent());

        super.setChanged();
        //通知观察者
        super.notifyObservers(weibo);
    }


}
